livecodefandomcom-20200223-history
Commands
Message Handlers are commonly called Handlers or Commands. LiveCode has many built-in Handlers, a list of them is found at the end of this article. A programmer can create their own Handlers, called Custom Handlers. This article is mainly about how to structure and use Custom Handlers. A Custom Message Handler is very similar to a Custom Function Handler. But there are differences, so don't confuse the two. However, which one you use usually comes down to personal preference. See also Function Handlers. Structure The first line of a Custom Handler must start with the word "on", followed my the name of the of the Handler. That name is also the name of the message which causes its execution. If there are any handler parameters, they are placed as a list after the name of the Handler. The last line of a Handler must start with the word "end", followed by the name of the Handler. Between the first and the last line of the Handler are the list of statements that make up the Handler. The statement list may include one or more Return statements, or none. The first Return statement that is executed stops the Handler execution and returns the value, it is the effective end of the Handler. A Handler example: on myWeek theDays -- myWeek has one parameter: theDays return theDays + 7 -- 7 is added to theDays, then it is end myWeek -- returned to the calling statement. Calling Statement The Calling Statement starts with the name of the Handler. If there are any function parameters, they are placed as a list after the name of the Handler in the Calling Statement. The parameter list in the Calling statement must match the parameter list in the Handler, both in the number of the parameters and the order. Each parameter in the parameter list of the Calling Statement must be an appropriate value or a variable containing the appropriate value. The Calling Statement is placed in any handler, which is then called the Calling handler. It is placed on a line by itself. When the Calling Statement is executed, the name and parameter list becomes the message which travels along the message path until it encounters the Handler, which is then executed. If a value is returned by the Handler, it is returned to the Calling Statement in a variable called "the result". The variable "the result" can be used by a lot of different handlers and functions to return a value, therefore its value changes throughout a program. So "the result" should be stored in another variable soon after it is returned. A Calling handler for the handler example above: on mouseUp -- mouseUp handler myWeek (4) -- myWeek is called put the result into thisWeek -- thisWeek = 11 answer "myWeek = " & thisWeek -- answer shows myWeek = 11 end mouseUp -- end mouseUp handler Another Handler example: on Fred george, bob, dude -- george 1st number, bob the 2nd and dude the 3rd put george + bob - dude into Temp -- Temp = 1st + 2nd - 3rd return Temp -- Temp is returned to the calling statement end Fred -- end Fred function Another Calling handler: on mouseUp -- This is the calling handler mouseUp Fred(4,5,6) -- Fred is called put the result into Susan -- Susan = 3 end mouseUp -- end mouseUp handler Private Handlers A Private Handler is placed in the same script as the Calling handler. When LiveCode executes a Calling Statement, it sends the message to the local script first. If a Private Handler is encountered, then LiveCode executes that Private Handler. The message doesn't travel far. The first line of a Private Handler must start with the word "private", followed by the word "command", followed my the name of the Handler. If there are any handler parameters, they are placed as a list after the name of the Handler. The parameter list of a Private Handler operates the same as the parameter list of a Handler. Common Built-in Handlers Please help to complete this list * accept * add * androidRequestPermission * answer * answer_color * answer_effect * answer_file * answer_folder * answer_page_setup * answer_printer * answer_record * ask * ask_file * ask_password * beep * breakpoint * blur * call * cancel * cancel_printing * choose * click * clone * close * close_driver * close file * close_printing * close process * close_socket * combine * compact * constant * convert * copy * create * create_alias * create_card * create_folder * create_stack * create_widget * crop * cut * debugdo * decrypt * decrypt_using_rsa * define * delete * delete_chunk * delete_file * delete_folder * delete_session * delete_stack * delete_url * delete_variable * difference * disable * disable_menu * dispatch * divide * do * do_in_widget * domenu * drag * drawer * DropboxAddFolderMember * DropboxCheckJobStatus * DropboxCheckShareJobStatus * DropboxCopy * DropboxCreateFolder * DropboxCreateSharedLinkWithSettings * DropboxDelete * DropboxDownload * DropboxGetAccount * DropboxGetAccountBatch * DropboxGetCurrentAccount * DropboxGetFolderMetadata * DropboxGetMetadata * DropboxGetPreview * DropboxGetSharedLinkFile * DropboxGetSharedLinkMetadata * DropboxGetSpaceUsage * DropboxGetThumbnail * DropboxListFolder * DropboxListFolderContinue * DropboxListFolderGetLatestCursor * DropboxListFolderLongPoll * DropboxListFolderMembers * DropboxListFolderMembersContinue * DropboxListFolders * DropboxListFoldersContinue * DropboxListMountableFolders * DropboxListMountableFoldersContinue * DropboxListRevisions * DropboxListSharedLinks * DropboxModifySharedLinkSettings * DropboxMountFolder * DropboxMove * DropboxPermanentlyDelete * DropboxRelinquishFolderMembership * DropboxRemoveFolderMember * DropboxRestore * DropboxRevokeSharedLink * DropboxSearch * DropboxShareFolder * DropboxTransferFolder * DropboxUnmountFolder * DropboxUnshareFolder * DropboxUpdateFolderMember * DropboxUpdateFolderPolicy * DropboxUpload * DropboxUploadSessionAppend * DropboxUploadSessionFinish * DropboxUploadSessionStart * edit * enable * enable_menu * encrypt * encrypt_using_rsa * export * export_snapshot * export_widget * export_with_palette * filter * find * flip * focus * get * global * go * go_in_widget * grab * group * hide * hide_groups * hide_menubar * hide_taskbar * hilite * httpdresponse *httpdstart *httpdstop * import * import_snapshot * import_widget * include * insert_script * intersect array * iphoneactivityindicatorstart * iphoneactivityindicatorstop * iphonecleartouches * iphonedisableremotecontrol * iphoneenableremotecontrol * iphonereachabilitytarget * iphonerequestproductdetails * iphonesetaudiocategory * iphonesetdonotbackupfile * iphonesetfiledataprotection * iphonesetheadingcalibrationtimeout * iphonesetkeyboardreturnkey * iphonesetnotificationbadgevalue * iphonesetreachabilitytarget * iphonesetredrawinterval * iphonesetremotecontroldisplay * iphonesetstatusbarstyle * iphonestarttrackingheading * iphonestarttrackinglocation * iphonestoptrackingheading * iphonestoptrackinglocation * iphoneusedeviceresolution * kill * launch * launch_document * launch_url * launch_url_in_widget * liburldownloadtofile * liburlfollowhttpredirects * liburlftpupload * liburlftpuploadfile * liburlsetauthcallback * liburlsetcustomhttpheaders * liburlsetexpect100 * liburlsetftplistcommand * liburlsetftpmode * liburlsetftpstoptime * liburlsetlogfield * liburlsetsslverification * liburlsetstatuscallback * load * load_extension * local * lock_clipboard * lock_colormap * lock_cursor * lock_error_dialogs * lock_menus * lock_messages * lock_moves * lock_recent * lock_screen * mark * mimeEncodeAsMIMEEmail * mobileadcreate * mobileaddcontact * mobileaddelete * mobileadregister * mobileadsettopleft * mobileadsetvisible * mobilebusyindicatorstart * mobilebusyindicatorstop * mobilecancelalllocalnotifications * mobilecancellocalnotification * mobilecleartouches * mobilecomposehtmlmail * mobilecomposemail * mobileComposeTextMessage * mobileComposeUnicodeMail * mobileControlCreate * mobileControlDelete * mobileControlDo * mobileControlSet * mobileCreateContact * mobileCreateLocalNotification * mobileDeleteSoundChannel * mobileDisableAccelerometer * mobileDisableNFCDispatch * mobileDisablePurchaseUpdates * mobileEnableAccelerometer * mobileEnableNFCDispatch * mobileEnablePurchaseUpdates * mobileExportImageToAlbum * mobileFindContact * mobileHideStatusBar * mobileLockIdleTimer * mobileLockOrientation * mobilePausePlayingOnChannel * mobilePick * mobilePickContact * mobilePickDate * mobilePickMedia * mobilePickPhoto * mobilePlaySoundOnChannel * mobilePurchaseConfirmDelivery * mobilePurchaseCreate * mobilePurchaseSendRequest * mobilePurchaseSet * mobilePurchaseVerify * mobileRemoveContact * mobileRestorePurchases * mobileResumePlayingOnChannel * mobileSetAllowedOrientations *mobileSetFullScreenRectForOrientations *mobileSetKeyboardDisplay * mobileSetKeyboardType * mobileSetSoundChannelVolume * mobileShowContact * mobileShowStatusBar * mobileStartTrackingSensor * mobileStopPlayingOnChannel * mobileStopTrackingSensor * mobileStoreConfirmPurchase * mobileStoreConsumePurchase * mobileStoreDisablePurchaseUpdates * mobileStoreEnablePurchaseUpdates * mobileStoreMakePurchase * mobileStoreRequestProductDetails * mobileStoreRestorePurchases * mobileStoreSetProductType * mobileStoreVerifyPurchase * mobileToast *mobileToastCancel * mobileUnlockIdleTimer * mobileUnlockOrientation * mobileUpdateContact * mobileVibrate * modal * modeless * move * multiply *OAuth2 *OAuth2Refresh * open_driver * open_file * open invisible * open_printing * open_printing_to_pdf * open_process * open_socket * option * palette * paste * place * play * play_file * play_video * pop * popup * Popup widget * post * prepare * prepare_image * print * print_anchor * print_bookmark * print_link * pulldown * push * put * put_binary * put_content * put_cookie * put_header * put_markup * put_text * put_unicode * qrCreate *qrSetColors * quit * read_from_driver * read_from_file * read_from_process * read_from_socket * record_pause * record_resume * record_sound * redo * relayer * remove * remove_script * rename * replace * reply * request * request_appleEvent * require * reset * reset_cursors * reset_paint * reset_printing * resetAll * resolve_image * revBrowserBack * revBrowserClose * revBrowserForward * revBrowserMakeTextBigger * revBrowserMakeTextSmaller * revBrowserNavigate * revBrowserPrint * revBrowserRedraw * revBrowserRefresh * revBrowserSet * revBrowserSnapshot * revBrowserStop * revCacheGeometry * revChangeWindowSize * revCloseCursor * revCloseDatabase * revCloseVideoGrabber * revCommitDatabase * revCopyFile * revCopyFolder * revDeleteFolder * revert * revExecuteSQL * revFontLoad * revFontUnload * revGoToFramePaused * revGoURL * revInitializeVideoGrabber * revLoadSpeech * revMail * revMailUnicode * revMoveFolder * revMoveToFirstRecord * revMoveToLastRecord * revMoveToNextRecord * revMoveToPreviousRecord * revMoveToRecord * revPlayAnimation * revPreviewVideo * revPrintField * revPrintReport * revPrintText * revRecordVideo * revRollBackDatabase * revRotatePoly * revSetCardProfile * revSetDatabaseDriverPath * revSetSpeechPitch * revSetSpeechProvider * revSetSpeechSpeed * revSetSpeechVoice * revSetSpeechVolume * revSetStackFileProfile * revSetStackProfile * revSetVideoGrabberRect * revSetVideoGrabSettings * revShowPrintDialog * revSpeak * revStopAnimation * revStopPreviewingVideo * revStopRecordingVideo * revStopSpeech * revUnloadSpeech * revUpdateGeometry * revVideoFrameImage * revVideoGrabDialog * revVideoGrabIdle * revVideoGrabSettings * revXMLAddDTD * revXMLAddNode * revXMLAppend * revXMLCopyNode * revXMLDeleteAllTrees * revXMLDeleteNode * revXMLDeleteTree * revXMLInsertNode * revXMLMoveNode * revXMLPutIntoNode * revXMLRPC_AddParam * revXMLRPC_DeleteAllDocuments * revXMLRPC_DeleteDocument * revXMLRPC_DeleteParam * revXMLRPC_GetMethod * revXMLRPC_SetHost * revXMLRPC_SetMethod * revXMLRPC_SetPath * revXMLRPC_SetPort * revXMLRPC_SetProtocol * revXMLRPC_SetSocket * revXMLSetAttribute * revZipAddItemWithData * revZipAddItemWithFile * revZipAddUncompressedItemWithData * revZipAddUncompressedItemWithFile * revZipCancel * revZipCloseArchive * revZipDeleteItem * revZipExtractItemToFile * revZipExtractItemToVariable * revZipOpenArchive * revZipRenameItem * revZipReplaceItemWithData * revZipReplaceItemWithFile * revZipSetProgressCallback * rotate * save * secure_socket * seek * select * send * send_to_program * set * sheet * show * show_cards * show_groups * show_menubar * show_taskbar * sort * sort_container * split * start * start_editing * start_session * start_using * start_using_font * stop * stop_editing * stop_moving * stop_recording * stop_session * stop_using * stop_using_font * subtract * topLevel * type * undefine * undo * ungroup * unhilite * union * unload * unload_extension * unlock_clipboard * unlock_colorMap * unlock_cursor * unlock_error_dialogs * unlock_menus * unlock_messages * unlock_moves * unlock_recent * unlock_screen * unmark * visual_effect * wait * write_to_driver * write_to_file * write_to_process * write_to_socket * XBrowser_Focus * XBrowser_Init * XBrowser_Unfocus Category:Commands